<h1>Leads</h1>
<?php
    $this->headTitle('Leads');
    $acl = $this->acl;
    $this->dojoLayer('common');
    $this->headScript()->appendFile('/js/BizSense/SavedSearch/Crud.js'); 
?>

<?php if  ($acl->isAllowed($this->currentUser, 'create leads')): ?>
<a href="<?php echo $this->url(array(
        'module'        =>  'default', 
        'controller'    =>  'lead', 
        'action'        =>  'create'
    )); ?>">Create lead</a>
<?php endif; ?>
|
<?php if  ($acl->isAllowed($this->currentUser, 'import leads')): ?>
<a href="<?php echo $this->url(array(
        'module'        =>  'default', 
        'controller'    =>  'lead', 
        'action'        =>  'import'
    )); ?>">Import leads</a>
<?php endif; ?>
|
<?php if ($acl->isAllowed($this->currentUser, 'administer leads')): ?>
    <a class="icon" href="<?php echo $this->url(
        array(
            'module' => 'lead', 
            'controller' => 'settings', 
            'action' => 'index'
        ), null, true
                        ); ?>">
                        
<span>Lead settings</span></a>
<?php endif; ?>

<fieldset class="fieldset_properties">
    <legend>
        <img src="/images/design/search.png"></li>
                     Search
     </legend>
        <?php echo $this->form; ?>
        <?php echo $this->savedSearchJs(Core_Model_SavedSearch::TYPE_LEAD); ?>
</fieldset>

<div class="clearing"></div>  

<?php
if (count($this->paginator)): ?>

<p>
Total leads : <?php echo $this->paginator->getTotalItemCount(); ?>
</p>
<table class="data_table">
<tr>
<th class="short">First Name <?php echo $this->sortButtons("firstName"); ?></th>
<th class="short">Last Name<?php echo $this->sortButtons("lastName"); ?></th>
<th class="short">Company Name<?php echo $this->sortButtons("companyName"); ?></th>
<th class="tiny_cell">Mobile<?php echo $this->sortButtons("mobile"); ?></th>
<th class="tiny_cell">Source<?php echo $this->sortButtons("leadSource"); ?></th>
<th class="tiny_cell">Status<?php echo $this->sortButtons("leadStatus"); ?></th>
<th class="tiny_cell">Action</th>
</tr>
<?php foreach ($this->paginator as $item): ?>
    <tr>
        <td>
            <?php
                echo $this->escape($item->first_name);
            ?>
        </td>
        <td>
            <?php
                echo $this->escape($item->last_name);
            ?>
        </td>
       <td>
            <?php
                echo $this->escape($item->company_name);
            ?>
        </td>
       <td>
            <?php
                echo $this->escape($item->mobile);
            ?>
        </td>
       <td>
            <?php
                echo $this->escape($item->lead_source_name);
            ?>
        </td>
        <td>
            <?php
                echo $this->escape($item->lead_status_name);
            ?>
        </td>

  	    <td> 
            <?php
			    echo "<a href=\"" . $this->url(
                    array(
                        'module' => 'default', 
                        'controller' => 'lead', 
                        'action' => 'viewdetails', 
                        'lead_id' => $this->escape($item->lead_id)
                    )
                ) . "\"> " . "View" . "</a>";
	        ?>
        </td>
    </tr>
<?php endforeach; ?>

<?php endif; ?>
</table>

<?php
        if ($this->wasSearched and !count($this->paginator)) {
            echo "<br />There are no records matching the search criteria";
        }
?>
<div class="pagination">
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'search.phtml'); ?>
</div>
<div class="div_clear"></div>


